package ddd.ajava.chapter6.question2;

import java.util.List;
import java.util.concurrent.Callable;

/**
 * 判断一个数是否为素数，是素数返回true，否则返回false
 *
 */
public class PrimeThread implements Callable<Boolean>{
	private Integer data=null;
	private List<Integer> tempPrime=null;
	
	public PrimeThread(Integer data,List<Integer> tempPrime){
		this.data=data;
		this.tempPrime=tempPrime;
	}
	
	@Override
	public Boolean call() throws Exception {
		boolean flag=true;
		for(int t:tempPrime){
			if(data%t==0&&data!=t){
				flag=false;
				break;
			}
		}
		System.out.println("data "+data+" handle thread name:"+Thread.currentThread().getName());
		return flag;
	}

}
